package com.ruoyi.member.service.impl;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.api.entity.resp.MobileUserInfo;
import com.ruoyi.api.feign.MemberApiService;
import com.ruoyi.member.entity.resp.MobileUserInfoResp;
import com.ruoyi.member.service.MobileUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class MemberApiServiceImpl implements MemberApiService {

    @Autowired
    private MobileUserService mobileUserService;

    @Override
    public R<MobileUserInfo> getInfo(Long userId) {
        R<MobileUserInfoResp> info = mobileUserService.getInfo(userId);
        if (R.isSuccess(info)){
            MobileUserInfoResp data = info.getData();
            MobileUserInfo mobileUserInfo = new MobileUserInfo();
            mobileUserInfo.setId(data.getId());
            mobileUserInfo.setName(data.getName());
            mobileUserInfo.setAvatar(data.getAvatar());
            mobileUserInfo.setProfile(data.getProfile());
            return R.ok(mobileUserInfo);
        }
        return R.ok();
    }

}
